<!--确认订单-->
<template>
  <view class="comfire_order">
    <onlineService></onlineService>
    <navBar v-if="isShowCustomNavBar" :navbarData.sync="navbarData"></navBar>
    <view class="address" @click="setAddress">
      <!-- 未设置地址 -->
      <view class="empty_address" v-if="!is_exit_address">
        <image class="location_icon" :src="locationIconImg"></image>
        <view class="phone_style">设置收货地址</view>
        <image class="arrow_right" :src="arrowRightIconImg"></image>
      </view>
      <view class="address_info" v-else>
        <image class="location_icon" :src="locationIconImg"></image>
        <view class="title_info">
          <view class="user_name">
            {{ address.receiverName }}
          </view>
          <view class="phone_style">
            {{ address.receiverMobile }}
          </view>
          <view class="phone_style">
            {{ address.receiverState }} {{ address.receiverCity }} {{ address.receiverDistrict }}
            {{address.receiverTown}}
            {{ address.receiverAddress }}
          </view>
        </view>
        <image class="arrow_right" :src="arrowRightIconImg"></image>
      </view>
    </view>

    <!-- 订单商品 -->
    <view class="goodsList">
      <block v-for="(item, index) in list" :key="index" v-if="item.isGift !== 1">
        <view class="list_box">
          <view class="goods-info">
            <navigator
              :url="'/pages/item/item?id=' + item.itemId + '&valueId=' + item.skuProperties[0].valueId + '&valueName=' + item.skuProperties[0].valueName"
              hover-class="none">
              <view class="img-box">
                <image :src="item.hdlpImageUrl ? item.hdlpImageUrl : item.skuImageUrl" class="img" />
              </view>
            </navigator>
            <view class="text-box">
              <navigator
                :url="'/pages/item/item?id=' + item.itemId + '&valueId=' + item.skuProperties[0].valueId + '&valueName=' + item.skuProperties[0].valueName"
                hover-class="none">
                <view class="goods-title" :class="isUserC2bOrder?'goods-title1':''">{{ item.itemName }}</view>
              </navigator>
              <view class="lable">
                <view class="bo-label">
                  {{ item.skuProperties[0].valueName }}
                </view>
              </view>
              <view class="bottomBox">
                <view class="font_24 color_000000">
                  <text class="mark font_24">¥</text>
                  {{ filterChecked.moneyFormat(item.price / 1, 2) }}
                </view>
                <view class="num-change ">
                  <view class="outerLayer flex_end" @click.stop="jianBtnTap(item,index)">
                    <image class="jian-btn "
                      :src="item.qty  === 1 ? goodsOperateBtn.delDisable : goodsOperateBtn.delActive">
                    </image>
                  </view>
                  <view class="buy-number cart_number_box" @click.stop="handleCartInputClick(item, index)">
                  	{{index === cartInputIndex ? cartInputVal :item.qty}}
                  </view>
									<input v-if="index === cartInputIndex"  v-model="cartInputVal" :focus="true"
										class="cart_number_input" type="number" 
										@input="handleCartNumberInput" @blur="handleCartNumberBlur" 
										:maxlength="2"
										:data-index="index" :data-id="item.skuId"/>
                  <view class="outerLayer flex_start" @click.stop="jiaBtnTap(item,index)">
                    <image class="jia-btn numjia "
                      :src="item.stockQty === item.qty || (item.qty >= item.limitPurchaseQty && item.limitPurchaseQty != -1) ? goodsOperateBtn.addDisable :  goodsOperateBtn.addActive">
                    </image>
                  </view>
                </view>
              </view>
            </view>
          </view>
					<view class="c2b_order_box" v-if="isUserC2bOrder">
						<view class="c2b_order_title">含个性化定制服务</view>
						<view class="c2b_order_btn" @click.stop="handleBackToC2BEdit(item.itemId, item.skuProperties[0].valueId)">编辑镌刻</view>
					</view>
        </view>
        <!-- </view> -->
      </block>
      <!-- 运费 -->
      <!-- <view class="distribution" v-if="address && address.customerAddressId"> -->
      <view class="distribution">
        <span class="font_24 color_000000" style="font-family: NotoSansSC-Medium;">配送服务</span>
        <span class="font_24 color_757575">{{ orderDetail.postFee == 0 ? '免费配送' : '¥ ' + filterChecked.moneyFormat(orderDetail.postFee, 2) }}</span>
      </view>
    </view>

    <!-- 订单备注 -->
    <view class="order-remarks" v-if="showCheckoutRemark && !isAgreement">
      <view class="title">买家备注</view>
      <view class="input"><input maxlength="100" type="text" @input="inputRemarks" @confirm="setRemarks"
          placeholder="选填" placeholder-style="color:#a4a4a4;opcity:0.5;" /></view>
    </view>
    <view class="order-remarks" v-else-if="showCheckoutRemark && isAgreement">
      <view class="title">买家备注</view>
      <view class="input">
        <view>{{orderRemarks}}</view>
      </view>
    </view>


    <!-- 温馨提示 -->
    <view class="tip_box" :class="showOrderDetails ? 'tip_box_show':'tip_box_hidden'">
      <view class="tip_inner">
        <text class="tip_icon color_757575 font_24">·</text>
        <text class="tip_text color_757575 font_24">个别区域受物流及其他政策暂停/暂缓派送的，以实际揽件时系统提示为准。</text>
      </view>
      <view class="tip_inner">
        <text class="tip_icon color_757575 font_24">·</text>
        <text class="tip_text color_757575 font_24">依据法律规定及公司政策，18周岁以下人士不得购买此类产品。</text>
      </view>

      <block v-if="openAppointment">
        <view class="tip_inner">
          <text class="tip_icon color_757575 font_24">·</text>
          <text class="tip_text color_757575 font_24">您了解并确认：您系基于生活消费购买、使用和接受本店的商品和服务。预约并非下单。在您提交预约申请后，小程序系统将对您的申请进行审核，待审核通过后，您方可获取相关商品的购买资格，在您随后提交订单并支付相关款项后，您提交的订单方可进入发货环节。如果您违反了以下任意内容：</text>
        </view>
        <view class="tip-text2 color_757575 font_24">
          a.<text style="padding-left: 20rpx;">法律法规</text>
        </view>
        <view class="tip-text2 color_757575 font_24">
          b.<text @click.stop="shoppingInstructions" class="check-dec" style="padding-left: 20rpx;">《THE MACALLAN麦卡伦线上精品店购物须知》</text>
        </view>
        <view class="tip-text2 color_757575 font_24">
          c.<text style="padding-left: 20rpx;">采用任何方式规避商品限购数量限制</text>
        </view>
        <view class="tip-text2 color_757575 font_24">
          我们有权拒绝向您提供小程序服务、商品或购买资格或采取其他合理措施。
        </view>
        <view class="tip-text2 color_757575 font_24">
          相关政策详见：<text @click.stop="shoppingInstructions" class="check-dec">《THE MACALLAN麦卡伦线上精品店购物须知》</text>或咨询在线客服。
        </view>
      </block>
    </view>

    <!-- 底部合计区域 -->
    <view class="bottomBar">
      <!-- 协议勾选 -->
      <view class="bottom-agreement">
        <view class="agreement">
          <view class="agreement-left" @click="checkboxChange">
            <image style="width: 100%;height:100%;" :src="checked ? selectedCheckboxImg: unselectedCheckboxImg"></image>
          </view>
          <view class="agreement-right color_757575 font_24">
            我已阅读并同意
            <text @click.stop="shoppingInstructions" class="check-dec">《THE MACALLAN麦卡伦线上精品店购物须知》</text>
            和
            <text @click.stop="drinkingProposal" class="check-dec">《理性饮酒倡议书》</text>
            并确认该商品不适用七天无理由退货。
          </view>
        </view>
      </view>

      <view class="bottom_submit">
        <view class="order_value_section" :class="showOrderDetails ? 'order_show':'order_hidden'">
          <view class="order_item">
            <view class="flex_style" @click.stop="handleOpenOrderDetails">
              <text class="title">合计</text>
              <image class="arrow_top" :class="showOrderDetails ? 'arrow_hidden' : 'arrow_show'" :src="arrowRightIconImg"></image>
            </view>
            <view class="flex_style">
              <text class="mark">¥</text>
              <text class="priceNum">{{ orderDetail.payment / 1 ? filterChecked.moneyFormat(orderDetail.payment, 2) : '' }}</text>
            </view>
          </view>
          <view class="order_item">
            <text class="title2">配送</text>
            <view class="flex_style">
              <text class="mark2">¥</text>
              <text class="priceNum2">{{ orderDetail.postFee == 0 ? '0.00' : filterChecked.moneyFormat(orderDetail.postFee, 2) }}</text>
            </view>
          </view>
          <view class="order_item">
            <text class="title2">商品总价</text>
            <view class="flex_style">
              <text class="mark2">¥</text>
              <text class="priceNum2">{{ orderDetail.payment / 1 ? filterChecked.moneyFormat(orderDetail.payment, 2) : '' }}</text>
            </view>
          </view>

        </view>
        <view class="pay_box">
          <form report-submit @submit="goPays">
            <button v-if="!canBuy" class="button type_green no-address">非配送地区不发货</button>
            <button v-else form-type="submit" class="button type_green"
              :class="checked ? '' : 'no-address'">{{openAppointment ? "提交预约申请" : "提交订单"}}</button>
          </form>
        </view>
      </view>
    </view>

    <!-- 弹窗 -->
    <errorTip v-if="isShowNotice" v-on:clickTap="isShow" :itemName.sync="itemName" :errorMessage.sync="errorMessage">
    </errorTip>
    <loading :showLoaded.sync="showLoaded"></loading>

    <!-- 优惠券弹窗 -->
    <view v-if="getCoupon == 1 && usableCoupon.length > 0">
      <view class="couponItem">
        <view style="height: 25px;">
          <view class="iconfont icon-cuowu1" @click="closeCoupon"></view>
        </view>
        <view class="coucontent" v-for="(item, index) in usableCoupon" :key="index">
          <view class="cousubstance" :data-couponCode="item.couponCode" :data-ruleName="item['couponRule'].ruleName"
            @click="useCoupon">
            <h4>{{ item['couponRule'].ruleName }}</h4>
            <view class="description">{{ item['couponRule'].description }}</view>
            <view class="copRule">有效期至 {{ item['couponRule'].toDate }}</view>
          </view>
        </view>
      </view>
    </view>

    <!-- 勾选协议弹框 -->
    <view class="popBg" v-if="isAgreement" @touchmove.stop.prevent catchtouchmove="true">
      <view class="bg-fix"></view>
      <view class="success-pop">
        <view>
          <i class="iconfont icon-cuowu1" @click="closeBox('关闭')"></i>
          <block v-if="openAppointment">
            <view class="title1">
              "您了解并确认：预约并非下单。如经系统审核，该预约申请存在异常或预约商品出现库存不足等情形时，则预约申请可能不成功。从而不能进入下单环节。该商品不支持7天无理由退换货，请谨慎预约。"
            </view>
          </block>
          <block v-else>
            <view class="title1 title-order">
              <view class="text">该商品不支持7天无理由退换货，</view>
              <view class="text">请谨慎下单。</view>
            </view>
          </block>
          <!--        <view class="title1">
            {{openAppointment ? "您了解并确认：预约并非下单。如经系统审核，该预约申请存在异常或预约商品出现库存不足等情形时，则预约申请可能不成功。从而不能进入下单环节。该商品不支持7天无理由退换货，请谨慎预约。" : "该商品不支持7天无理由退换货，请谨慎下单。"}}
          </view> -->
        </view>
        <view class="btn-bg">
          <view class="btnStyle btn1" @click.stop="closeBox('再想想')">再想想</view>
          <view class="btnStyle btn2" @click.stop="goPay">{{openAppointment ? "提交预约申请" : "确认下单"}}</view>
          <!-- <view class="btnStyle btn2" @click.stop="goPay">提交预约申请</view> -->
        </view>
      </view>
    </view>
    <completeStreet v-if="showStreetDialog" :orderAddressId='orderAddressId' operateHandle='submit'
      @closeStreetDialog='closeStreetDialog'></completeStreet>
		<!-- 弱提示 弹窗 -->
		<toast-popup ref="toastPopup" @onToastPopupClick="onToastPopupClick"></toast-popup>
		<!-- 个性化定制商品下单 确认弹窗 -->
		<c2bConfirm v-if="showC2bConfirmDialog" @onC2bConfirmClick="onC2bConfirmClick"></c2bConfirm>
  </view>
</template>
<script module="filterChecked" lang="wxs" src="../../utils/filter.wxs"></script>
<script>
  import api from '@/api/api';
  import tip from '@/utils/tip';
  import NavBar from '../../components/common/navbar';
  import util from '@/utils/util';
  import {
    USER_SPECICAL_INFO,
    CUSTOMER_INFO,
    MERCHANT_INFO,
    ADDRESS_ID,
    CART_KEY
  } from '@/utils/constant';
  import ErrorTip from './errorTip';
  import Loading from '@/components/common/loading';
  import onlineService from '@/components/common/onlineService';
  import completeStreet from './components/completeStreet.vue';
  import commonImages from '@/utils/commonImages';
	import c2bConfirm from './components/c2bConfirm.vue';
  import {
    requestSubscribeMessageSync,
    getWaitForPayTemplateId,
    sendWaitForPaySubscribeMessage
  } from "@/utils/wx-subscribe-request";

  export default {
    config: {
      navigationBarTitleText: '确认订单'
    },
    components: {
      navBar: NavBar,
      errorTip: ErrorTip,
      onlineService: onlineService,
      loading: Loading,
      completeStreet: completeStreet,
			c2bConfirm: c2bConfirm
    },
    computed: {
      haveToSubscribWaitForPay() {
        // if (this.orderDetail?.items?.length) {
        //   // TS活动不需要待付款订阅消息
        //   const tsActivityMark = this.orderDetail.items.some(item => item.tsActivityMark === 1);
        //   return !tsActivityMark;
        // }
        return true;
      }
    },
    data() {
      return {
        isShowCustomNavBar: true,
        // 组件所需的参数
        navbarData: {
          showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
          navbarTitle: this.$programSetting.openAppointment ? "填写预约申请信息" : "提交订单", //导航栏 中间的标题
          hideHome: false
        },
        isShowNotice: false,
        orderDetail: {},
        list: [],
        goodsId: '',
        //卖家留言
        sellerMessage: '',
        couponMessage: '',
        discountMessage: '',
        //是否存在默认地址
        is_exit_address: false,
        address: {},
        totalPrice: 0, //总价
        purchaseType: 1,
        operating: false,
        payType: ' ',
        payTypeChange: '',
        payTypeArr: [],
        orderId: '',
        orderCode: '',
        isShowCouponList: false,
        couponMessage: '',
        couponValue: '',
        couponShow: false,
        itemName: [],
        subscribeMessage: [],
        postFee: '',
        cartBagItems: [],
        couponValue: '',
        couponShow: false,
        itemName: [],
        showLoaded: false,
        subscribeMessage: [],
        discountFee: '',
        postFee: '',
        itemTotal: '',
        getCoupon: 0, // 是否显示可用优惠券
        couponRuleIds: '',
        usableCoupon: [], // 可用优惠券列表
        couponRuleName: '',
        giftName: '',
        errorMessage: '',
        discountsArr: [],
        imageHeight: 206,
        interval: {},
        timer: 30, //订单状态轮循查询次数
        orderRemarks: '',
        formId: '',
        showCheckoutRemark: false,
        realCartKey: '',
        cartToBuy: false,
        couponFee: 0,
        showUseCoupon: false, //  是否展示输入优惠券的文本框
        saveCoupon: '',
        errorCouponWarn: '',
        onlyFreight: false, //只含运费促销
        checked: false,
        isAgreement: false,
        nowPages: '',
        touchStartTime: '',
        skuIdArr: [],
        canBuy: true,
        showStreetDialog: false,
        orderAddressId: '',
        isSystem: false,
        isIpx: false,
        openAppointment: this.$programSetting.openAppointment,
        checkOrderId: 0,
        waitForPayTemplateId: "", // 待付款订阅消息模板id
        needSendWaitForPaySubscribeMessage: false, // 是否要发送待付款订阅消息
        goodsOperateBtn: commonImages,
        locationIconImg: "",
        arrowRightIconImg: "",
        unselectedCheckboxImg: "",
        selectedCheckboxImg: "",
        showOrderDetails: false,
				isUserC2bOrder: false,	//	当前订单是否为c2b订单
				customizationDetails: null,	//	获取用户个性化定制信息
				showC2bConfirmDialog: false, // 个性化定制下单确认弹窗
				
				cartInputVal: 1,	//	键盘修改数量
				cartInputIndex: -1
      };
    },
    onLoad(option) {
      let that = this;
      that.showLoaded = true;
      const { locationSvgImg, arrowRightSvgImg,unselectedCheckboxSvgImg,selectedCheckboxSvgImg } = require('./imgs.svg.js');
      this.locationIconImg = locationSvgImg('#000');
      this.arrowRightIconImg = arrowRightSvgImg("#757575");
      this.unselectedCheckboxImg = unselectedCheckboxSvgImg();
      this.selectedCheckboxImg = selectedCheckboxSvgImg();

      // that.navbarData.navbarTitle = this.$programSetting.openAppointment ? "填写预约申请信息" : "提交订单"
      // that.openAppointment = this.$programSetting.openAppointment

      let pages = getCurrentPages();
      let prevPage = pages[pages.length - 2];
			//	订单页路由白名单
      const _routeWhiteList = ['pages/item/item', 'pages/item/goodsLetteringNew'];
      that.cartToBuy = _routeWhiteList.includes(prevPage?.route) ? true : false;
      that.realCartKey = _routeWhiteList.includes(prevPage?.route) ? uni.getStorageSync('buyNowCartKey') : uni.getStorageSync('cartKey');
			
			// 个性化定制参数
			this.isUserC2bOrder = option?.type === 'C2B' ? true : false;
			this.customizationDetails = uni.getStorageSync('userCustomizationDetails');
			
      this.imageHeight = 136 / uni.getStorageSync('imageScaling');
      that.actualPrice = 0;
      that.totalPrice = 0;
      that.total_jf_num = 0;
      that.can_use_score = 0;
      that.deduScore = 0;
      that.deduFee = 0;
      that.jf_num = 0;
      that.reduce_fee = 0;
      that.operating = false;
      that.goodsId = option.goodsId === undefined ? '' : option.goodsId;
      that.setPayType();
      that.skuIdArr = option.skuIdArr && JSON.parse(decodeURIComponent(option.skuIdArr))
      // that.skuIdArr = [809003]
      this.sourceBind();
      that.showCheckoutRemark = getApp().globalData.showCheckoutRemark;
      this.isSystem = getApp().globalData.isSystem;
      this.isIpx = getApp().globalData.isIpx
    },
    onShow() {
      let that = this;
      if (that.checkOrderId !== 0) {
        that.showLoaded = true
        let flagOrderId = that.checkOrderId
        that.checkOrderId = 0
        that.$commonFunction.getOrderInfo(flagOrderId).then((res) => {
          if (res.status == 'WAIT_BUYER_PAY' || res.status == 'BUYER_PART_PAYMENT') {
            uni.redirectTo({
              url: "/pages/order/list",
            });
          } else if (res.status == 'WAIT_SELLER_SEND_GOODS') {
						uni.redirectTo({
							url: '/pages/order/paySuccess?orderNo=' + flagOrderId
						});
          } else {
            uni.redirectTo({
              url: "/pages/order/list",
            });
          }
        }).catch((err) => {

        })
      }
      if (that.realCartKey !== null) {
        that.getDefaultAddress();
      }
      let pages = getCurrentPages();
      var currPage = pages[pages.length - 1];
      this.nowPages = currPage.route;
      getApp().cl_tracker.track('mini_program_view', {
        path: this.nowPages,
        pageName: this.$programSetting.openAppointment ? "填写预约申请信息" : "提交订单",
      })
      setTimeout(() => {
        that.$commonSensors.commonOrderView('CheckoutPageView',that.list)
      }, 2000)
    },
    methods: {
			//	返回刻字页面
			handleBackToC2BEdit(itemId,valueId){
        uni.navigateTo({
          url:  `/pages/item/goodsLetteringNew?itemId=${itemId}&valueId=${valueId}&type=toGoodsLetteringNew`
        })
				// uni.navigateBack();
			},
			/**
			 * 个性化定制订单确认弹窗 回调方法
			 * @param {Object} type  关闭弹窗CLOSE、确认提交订单SUBMIT_ORDER、查看c2b规则C2B_RULES
			 */
			onC2bConfirmClick(type){
				if(type === 'CLOSE'){
					this.showC2bConfirmDialog = false;
				}else if(type === 'SUBMIT_ORDER'){
					this.showC2bConfirmDialog = false;
					//	提交订单
					this.goPay();
				}else if(type === 'C2B_RULES'){}
			},
			/**
			 * c2b规则弹窗回调方法
			 * @param {Object} data.type 事件类型：C2B_NO无需定制、C2B_YES前往定制、C2B_TIPS未勾选规则须知、C2B_CLOSE关闭弹窗
			 */
			onC2BrulesEvent(data){
				// const { type } = data;
			},
			/**
			 * 展示弱提示
			 * @param {Object} msg 文案
			 */
			handleShowTextToast(msg){
				try{
					this.$refs.toastPopup.showToast(msg);
				}catch(e){}
			},
			/**
			 * 若提示按钮点击回调
			 * @param {Object} data.type 类型：confirm确定，cancel取消
			 * @param {Object} data.callBackData 呼气弹窗时传入的数据
			 */
			onToastPopupClick(data){
				const {type,callBackData} = data;
				//	用户未设置收货地址 弹窗确认
				if(type === 'confirm' && callBackData && callBackData.type === "setUserAddress"){
					uni.navigateTo({
					  url: '/pages/customer/address?type=order'
					});
				}
			},
      //  合计 展开折叠动画
      handleOpenOrderDetails(){
        this.showOrderDetails = !this.showOrderDetails;
      },
      jianBtnTap(item, index) {
        let id = item.skuId;
        var num = item.qty;
        // 如果只有1件了，就不允许再减了
        if (num === 1) {
          this.operating = true;
          this.handleShowTextToast('购买数量低于购买范围')
          return;
        } else {
          num = -1;
          this.operating = false;
          this.addGoodNum(id, num, index);
        }

      },
      jiaBtnTap(item, index) {
        let id = item.skuId;
        let qty = this.list[index].qty;
        let stockQty = this.list[index].stockQty;
        let limitPurchaseQty = this.list[index].limitPurchaseQty;

        //库存不足
        if (qty === stockQty) {
          this.handleShowTextToast('商品库存不足')
          this.operating = true;
          return false;
        } else {
          if (qty >= limitPurchaseQty && limitPurchaseQty != -1) {
            this.handleShowTextToast('已超出限购数量，详情请咨询顾问');
            this.operating = true;
            return false;
          }
					if(this.isUserC2bOrder) this.handleShowTextToast('多件商品默认享受相同定制服务');
          let num = 1;
          this.operating = false;
          this.addGoodNum(id, num, index);
        }
      },
			/**
			 * 点击数量 调起键盘修改
			 * @param {Object} item
			 */
			handleCartInputClick(item, index){
				this.cartInputVal = item.qty;
				this.cartInputIndex = index;
			},
			/**
			 * 输入框输入时回调方法
			 * @param {Object} e
			 */
			handleCartNumberInput(e){
				// const {currentTarget:{dataset:{index, id}}, detail:{value}} = e;
				// let _index = parseInt(index);
				// const _tag = this.list[_index];
				// let limitPurchaseQty = _tag.limitPurchaseQty;
				// let qty = _tag.qty;
				// const reg = /^\d+$/;
				// if(value && !reg.test(value)){
				// 	this.cartInputVal = qty;
				// 	return this.handleShowTextToast('请输入数字');
				// }
				// let _val = parseInt(value);
				
				// if(_val <= 0){
				// 	this.cartInputVal = 1;
				// 	return this.handleShowTextToast('购买数量低于购买范围');
				// }
				
				// if (_val >= limitPurchaseQty && limitPurchaseQty != -1) {
				//   this.handleShowTextToast('已超出限购数量，详情请咨询顾问')
				//   return false;
				// }
			
			},
			/**
			 * 输入框修改商品数量
			 * @param {Object} e
			 */
			handleCartNumberBlur(e){
				const {currentTarget:{dataset:{index, id}}, detail:{value}} = e;
				
				let _index = parseInt(index);
				const _tag = this.list[_index];
				if(_tag){
					let qty = _tag.qty;
					let stockQty = _tag.stockQty;
					let limitPurchaseQty = _tag.limitPurchaseQty;
					if(!value){
						this.cartInputIndex = -1;
						return this.cartInputVal = qty;
					}
					const reg = /^\d+$/;
					if(value && !reg.test(value)){
						this.cartInputVal = qty;
						this.cartInputIndex = -1;
						return this.handleShowTextToast('请输入数字');
					}
					let _val = parseInt(value);
					if(_val <= 0){
						this.cartInputVal = 1;
						_val = 1;
						this.handleShowTextToast('购买数量低于购买范围');
					}
					if(_val === qty){
						return this.cartInputIndex = -1;
					}
					
					if(limitPurchaseQty != -1){
						if (_val >= limitPurchaseQty) {
							this.cartInputVal = limitPurchaseQty;
							_val = limitPurchaseQty;
						  this.handleShowTextToast('已超出限购数量，详情请咨询顾问');
						}
					}else{
						if(_val > stockQty){
							this.cartInputVal = stockQty;
							_val = stockQty;
							this.handleShowTextToast('商品库存不足');
						}
					}
					this.addGoodFullNum(id, _val, _index);
				}
			},
			/**
			 * 修改商品数量(全量形式)
			 * @param id
			 * @param num
			 * @param index
			 * @returns {Promise<void>}
			 */
			addGoodFullNum: async function(id, num, index) {
			  let that = this;
			  let cart_key = that.realCartKey;
			  let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
			  const json = await api.cartUpdateNumFull({
			      method: 'PUT',
			      header: {
			        jwt: jwt
			      },
			      query: {}
			    },
			    cart_key,
			    num,
			    id
			  );
			  if (json.code === 1000) {
			    that.operating = false;
			    // 购物车数据
			    that.getCartList();
			  } else if (json.code === -1002) {
			    this.handleShowTextToast('购买数量低于购买范围')
			  } else if (json.code === -1010) {
			    this.handleShowTextToast('已超出限购数量，详情请咨询顾问')
			  } else {
			    this.handleShowTextToast(json.msg)
			  }
				setTimeout(()=>{
					this.cartInputIndex = -1;
					// this.cartInputVal = 1;
				}, 500)
			},
      /**
       * 修改商品数量(增量形式)
       * @param id
       * @param num
       * @param index
       * @returns {Promise<void>}
       */
      addGoodNum: async function(id, num, index) {
        let that = this;
        let cart_key = that.realCartKey;
        let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
        const json = await api.cartUpdateNum({
            method: 'PUT',
            header: {
              jwt: jwt
            },
            query: {}
          },
          cart_key,
          num,
          id
        );
        if (json.code === 1000) {
          that.operating = false;
          // 购物车数据
          that.getCartList();
        } else if (json.code === -1002) {
          this.handleShowTextToast('购买数量低于购买范围')
        } else if (json.code === -1010) {
          this.handleShowTextToast('已超出限购数量，详情请咨询顾问')
        } else {
          this.handleShowTextToast(json.msg)
        }
      },

      // 关闭补充街道信息弹窗
      closeStreetDialog() {
        this.showStreetDialog = false
      },
      // 购物须知
      shoppingInstructions() {
        uni.navigateTo({
          url: '/pages/utcms/utcms?uttype=shoppingInstructions'
        });
      },
      // 饮酒倡议书
      drinkingProposal() {
        uni.navigateTo({
          url: '/pages/utcms/utcms?uttype=drinkingProposal'
        });
      },
      // 关闭提交订单二次弹框
      closeBox(btnName) {
        let that = this;
        that.trackOrderConfirm('再想想')
        that.isAgreement = false;
        that.$commonSensors.popupEvent('PopupClick', {'popup_type' : '购买', 'popup_name': '确认提交订单弹窗', 'button_name': btnName ? btnName : '再想想'})
      },

      //商城-订单-确认订单---用户在确认订单页面点击“再想想/确认下单”后返回此数据
      trackOrderConfirm(type, orderData = '') {
        let that = this;
        let clTrackPrams = {
          'c_confirm_result': type,
          'c_product_id': '',
          'c_product_name': '',
          'c_product_brand': '',
          'c_product_price': '',
          'c_product_year': '',
          'c_product_series': '',
          'c_product_scenarios': '',
          'c_product_taste': '',
          'c_product_alcoholconcentration': '',
          'c_product_volume': '',
          'c_order_id': !!orderData ? orderData.orderCode : '',
          'c_quantity': this.orderDetail.checkedTotalQty,
          'c_order_remark': '',
          'c_amount': this.orderDetail.payment,
          'c_campaignID': '',
          'c_campaignName': '',
          'c_order_type': '常规活动',
          'c_purchase_type': this.$programSetting.openAppointment ? "立即预约" : "立即购买",
        }

        that.list.forEach(function(item, index) {
          clTrackPrams.c_product_id += item.itemId + ';';
          clTrackPrams.c_product_name += item.itemName + ';';
          clTrackPrams.c_product_price += item.price + ';';
          clTrackPrams.c_product_volume += item.skuProperties[0].valueName + ';';
        });
        getApp().commonClTrack('c_ebmp_order_confirm', clTrackPrams)
      },
      // 协议勾选
      checkboxChange() {
        this.checked = !this.checked;
      },

      inputRemarks(e) {
        this.orderRemarks = e.detail.value;
      },
      /**
       * @param {Object} value
       * @param {Object} type 输入备注的类型 可传input，done
       */
      async setRemarks(text, type) {
        let that = this;
        let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let inputValue = '';
        if (type == 'input') {
          inputValue = text;
        } else {
          inputValue = text.detail.value;
        }

        if (inputValue !== '' && inputValue !== undefined) {
          let content = inputValue;
          const accountInfo = uni.getAccountInfoSync()
          let customerInfo = uni.getStorageSync('customerInfo') || getApp().globalData.customerInfo;
          let appId = accountInfo.miniProgram.appId
          const checkText = await api.checkText({
              method: 'POST',
              header: {
                'Content-Type': 'application/json'
              },
              query: {
                content: content
              }
            },
            appId
          );
          if (checkText.code == 1000) {
            if (type == 'input') {
              that.testAddress(uni.getStorageSync(ADDRESS_ID), that.formId);
            }
            const resultJson = await api.setOrderRemarks({
                method: 'PUT',
                header: {
                  jwt: jwt
                },
                query: {
                  buyerRemark: inputValue
                }
              },
              that.realCartKey
            );
            if (resultJson.code == 1000) {
              that.testAddress(uni.getStorageSync(ADDRESS_ID), fId);
            }
          } else {
            this.handleShowTextToast('含敏感文字，请修改');
            that.showLoaded = false
          }
        }
      },

      getDefaultAddress: async function() {
        let that = this;
        let storageId = uni.getStorageSync('addressId');
        this.getAddressInfo(storageId);

      },

      // 设置支付方式
      setPayType: async function() {
        // 获取商户配置属性 判断是微信还是收钱吧
        let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        if (merchantInfo) {
          let merchantId = merchantInfo.cloudMerchantId;
          const configPayType = await api.checkoutPayType({
            header: {
              jwt: jwt
            },
            query: {
              config_name: 'PayTypeList',
              merchant_id: merchantId
            }
          });
          if (configPayType.code == 1000) {
            let configValue = configPayType.data.configValue;
            this.payTypeArr = JSON.parse(configValue);
            this.payTypeChange = this.payTypeArr[0];
            if (this.payTypeChange == 'Shouqianba') {
              this.payType = 'wosai:weixin:mini';
            }
            if (this.payTypeChange == 'Wechat') {
              this.payType = 'weixin';
            }
            if (this.payTypeChange == 'GiftCard') {
              this.payType = 'wosai:weixin:mini:giftcard';
            }
          }
        }
      },
      //获取购物车商品列表
      getCartList: async function() {
        let that = this;
        // that.showLoaded = true;
        let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
        // that.cartItems(that.realCartKey);
        const json = await api.checkoutOrder({
            method: 'PUT',
            header: {
              jwt: jwt
            }
          },
          that.realCartKey
        );
        if (json.code === 1000) {
          let discountsArr = [];
          this.orderDetail = json.data;
          this.discountFee = json.data.discountFee;
          this.postFee = json.data.postFee;
          this.itemTotal = json.data.itemTotal;
          this.list = json.data.items;
          this.totalPrice = json.data.total;
          let tempPayType = json.data.payType;
          that.payType = tempPayType;
          switch (tempPayType) {
            case 'weixin':
              that.payTypeChange = 'Wechat';
              break;
            case 'wosai:weixin:mini':
              that.payTypeChange = 'Shouqianba';
              break;
            case 'wosai:weixin:mini:giftcard':
              that.payTypeChange = 'GiftCard';
              break;
            default:
              that.payTypeChange = 'Shouqianba';
              break;
          }
          for (let i = 0; i < this.list.length; i++) {
            if (this.list[i].discounts && this.list[i].discounts.length > 0) {
              for (let j = 0; j < this.list[i].discounts.length; j++) {
                if (this.list[i].discounts[j].isCoupon == 0 && discountsArr.indexOf(this.list[i].discounts[j]
                    .discountName) == -1) {
                  discountsArr.push(this.list[i].discounts[j].discountName);
                }
              }
              if (!!this.orderDetail.couponRuleName) {
                // discountsArr.indexOf(this.orderDetail.couponRuleName) == -1
              }
            }
            if (this.list[i]['skuProperties']) {
              this.list[i].skuProperties = JSON.parse(this.list[i]['skuProperties']);
            }
            if (this.list[i].discounts != null) {
              this.list[i].discounts.sort(function(a, b) {
                return a.discountId - b.discountId;
              });
            }
            if (this.list[i].isGift == 1) {
              this.giftName = this.list[i].itemName;
            }
          }
          this.discountsArr = discountsArr;
          if (this.discountsArr.length == 1) {
            this.discountsArr[0].indexOf('运费') !== -1;
            this.onlyFreight = true;
          } else {
            this.onlyFreight = false;
          }
          that.showLoaded = false;
          that.operating = true;

        } else {
          this.showLoaded = false;
        }
      },

      /**
       * 获取提交订单时选择地址并设置地址和设置支付方式
       * @param id
       * @returns {Promise<void>}
       */
      getAddressInfo: async function(id) {

        let that = this;
        // 检测区域是否配送
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let customerId = customerInfo.customerId;
        let jwt = customerInfo.jwt;
        // 获取商户配置属性 判断是微信还是收钱吧
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let merchantId = merchantInfo.cloudMerchantId;
        if (that.payType == '' || that.payType == undefined || that.payType == null) {
          that.setPayType();
        }

        if (!id) {
          that.address = null;
          that.canBuy = true
          this.is_exit_address = false;
          // that.showLoaded = false
          that.getCartList();
          that.getCouponList();
          return false
        }

        // 获取顾客地址信息
        const json = await api.getAddressInfoById({
            header: {
              jwt: jwt
            }
          },
          customerId,
          id
        );
        if (json.code === 1000) {
          // 广东省东莞市 441900000
          // 广东省中山市 442000000
          // 海南省儋州市 460400000
          let noStreetDistict = ['东莞市', '中山市', '儋州市']
          let noStreet = noStreetDistict.indexOf(json.data.receiverCity)
          if (!!json.data && !json.data.receiverTown && noStreet == -1) {
            that.showStreetDialog = true
            that.orderAddressId = id
          } else {
            this.checkDistrict(id)
          }
          this.address = json.data;
          this.is_exit_address = true;
          const json1 = await api.setOrderAddressId({
              method: 'PUT',
              header: {
                jwt: jwt
              }
            },
            that.realCartKey,
            id
          );
          const json2 = await api.setOrderPayType({
              method: 'PUT',
              header: {
                jwt: jwt
              }
            },
            that.realCartKey,
            this.payType
          );
          //设置地址和设置支付方式都成功才继续生成订单
          if (json1.code === 1000 && json2.code === 1000) {
            that.operating = true;
            that.getCartList();
            that.getCouponList();
          }
        } else {
          that.canBuy = true
          that.address = null;
          this.is_exit_address = false;
          that.getCartList();
          that.getCouponList();
        }

      },

      // 点击提交订单再次选择地址并设置地址和设置支付方式
      testAddress: async function(id, fId) {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let customerId = customerInfo.customerId;
        let jwt = customerInfo.jwt;
        // 获取商户配置属性 判断是微信还是收钱吧
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let merchantId = merchantInfo.cloudMerchantId;

        if (that.payType == '' || that.payType == undefined || that.payType == null) {
          await that.setPayType();
        }

        // 获取顾客地址信息
        const json = await api.setOrderAddressId({
            method: 'PUT',
            header: {
              jwt: jwt
            }
          },
          that.realCartKey,
          id
        );
        const json2 = await api.setOrderPayType({
            method: 'PUT',
            header: {
              jwt: jwt
            }
          },
          that.realCartKey,
          this.payType
        );
        if (json.code === 1000 && json2.code === 1000) {
          that.goToPay(fId);
        } else if (json.code !== 1000) {
          that.showLoaded = false
          this.handleShowTextToast(json.msg)
        } else if (json2.code !== 1000) {
          that.showLoaded = false
          this.handleShowTextToast(json2.msg)
        }
      },

      // 获取模板ID
      getTmplIds: async function() {
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        const tmplIds = await api.customize({
          method: 'POST',
          query: {
            cloudMerchantId: merchantInfo.cloudMerchantId,
            cloudMerchantStoreId: merchantInfo.cloudMerchantStoreId,
            cloudStoreConfigtypeId: 59,
            cloudStoreConfigtypeName: 'Mini_Subscribe_Message_Config'
          }
        });
        if (tmplIds.code == 200) {
          if (!!tmplIds.data && !!tmplIds.data.cloudStoreConfigText) {
            const configText = tmplIds.data.cloudStoreConfigText;
            let configTextParse = JSON.parse(configText);
            let orderMessage = [];
            // 下单成功提醒
            if (configTextParse.paymentMsg == 1) {
              orderMessage.push(configTextParse.paymentTemplateId);
            }
            // 订单发货提醒
            if (configTextParse.shipmentMsg == 1) {
              orderMessage.push(configTextParse.shipmentTemplateId);
            }
            // 订单退款提醒
            if (configTextParse.applyRefundMsg == 1) {
              orderMessage.push(configTextParse.applyRefundTemplateId);
            }
            this.subscribeMessage = orderMessage;
          }
        }
      },
      // 检测地区是否可以配送
      async checkDistrict(id) {
        if (!id) {
          this.canBuy = true
          return false
        }
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO) || getApp().globalData.merchantInfo;
        const json = await api.checkDistrict({
          method: 'POST',
          header: {
            jwt: customerInfo.jwt
          },
          query: {
            skuIds: this.skuIdArr,
            customerAddressId: id,
            storeId: merchantInfo.cloudMerchantStoreId,
          }
        })
        if (json.code == 1000) {
          this.canBuy = true
        } else {
          this.canBuy = false
        }
      },
      goToPay: async function(formId) {
        let that = this;
        that.getTmplIds();
        uni.showLoading({
          title: that.openAppointment ? '提交预约中' : '提交订单中',
          mask: true
        });
        that.showLoaded = false
        try {
          let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
					let _params = {
						cartKey: that.realCartKey
					}
					//	如果是个性化定制订单需要传输定制内容和定制图片
					if(that.isUserC2bOrder){
						const _info = uni.getStorageSync('userCustomizationDetails');
						let _text1 = "";
						let _text2 = "";
						if(_info.submitArr && _info.submitArr.length){
							let _textLists1 = _info.submitArr[0] || [];
							let _textLists2 = _info.submitArr[1] || [];
							for (let i = 0; i < _textLists1.length; i++) {
								_text1 += _textLists1[i];
							}
							for (let k = 0; k < _textLists2.length; k++) {
								_text2 += _textLists2[k];
							}
						}
						_params.customization = `${_text1}/${_text2}`;
						_params.customizationImg = _info.subImg.join(";");
						console.log('######   定制参数：：', _params)
					}
					
          // 支付前生成订单 新增订单
          const json = await api.saveByCart({
            method: 'POST',
            header: {
              jwt: customerInfo.jwt
            },
            query: _params
          });
          if (json.code !== 1000) {
            uni.hideLoading()
            that.errorMessage = json.msg;
            // that.isShowNotice = true;
            // 部分区域不支持发货时
            let understock = json.msg.indexOf('商品库存不足')
            if (understock != -1) {
              this.handleShowTextToast('商品库存不足')
            } else {
              this.handleShowTextToast(json.msg);
            }

            let itemInfo = [];
            let errorInfo = [];
            itemInfo = json.msg.split('，');
            errorInfo = itemInfo[1].split('：');
            that.itemName = errorInfo[1];
          }
          //提交订单就去删除上一次的选择地址
          if (json.code === 1000) {
            that.youshuTrack(json)
            tip.loaded();
            that.$commonFunction.getCartList().then((res) => {

            }).catch((err) => {

            });
            that.orderId = json.data.orderId;
            let changeOrderIdType = JSON.stringify(that.orderId);
            let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
            let userSpecialInfo = uni.getStorageSync(USER_SPECICAL_INFO) || {};

            //商城-订单-确认订单
            that.trackOrderConfirm('确认下单', json.data);
            that.$commonSensors.popupEvent('PopupClick', {'popup_type' : '购买', 'popup_name': '确认提交订单弹窗', 'button_name': '确认下单'})
            const {
              orderCode,
              orderId,
              orderTime
            } = json.data;

            //  utm投放渠道参数 同步EF
            that.$commonFunction.handleSaveUtmByOrder(customerInfo,merchantInfo,orderCode);
            if (this.needSendWaitForPaySubscribeMessage) {
              sendWaitForPaySubscribeMessage(orderCode)
            }
            uni.hideLoading()
            //EFSTracking Order
            if (!that.openAppointment) {
              that.checkOrderId = json.data.orderId
              that.$commonFunction.getOrderInfo(json.data.orderId).then((res) => {
                let orderFlow = that.$programSetting.openAppointment;
                let objOrder = that.$commonFunction.isOrderType(res, orderFlow);
                that.$commonFunction.payMoney(res, that,objOrder).then((res) => {
                }).catch((err) => {
                  uni.redirectTo({
                    url: '/pages/order/list'
                  });
                })
              }).catch((err) => {

              })

            } else {
              uni.redirectTo({
                url: '/pages/order/submitSuccess?orderNo=' + json.data.orderId
              });
            }
            that.$commonSensors.saveByCartTrack(json.data.orderCode, that.orderDetail, that.list, that.address)
            // let enableMatomo = uni.getStorageSync('enableMatomo');
            // if (enableMatomo === true) {
            //   const orderJson = await api.getOrderInfo({
            //       header: {
            //         jwt: customerInfo.jwt
            //       }
            //     },
            //     that.orderId
            //   );
            //   if (orderJson.code === 1000) {
            //     let obj = orderJson.data;
            //     let orderItems = obj.items;
            //     //解析每个数组下面的items.skuProperties属性
            //     orderItems.forEach(function(item, index, array) {
            //       getApp().matomo.addEcommerceItem(item.skuCode, item.itemName, '全部商品', item.price / 1, item.qty);
            //     });
            //   }
            //   getApp().matomo.trackEcommerceOrder(changeOrderIdType, that.totalPrice, that.itemTotal, 0, that.postFee,
            //     that.discountFee);
            // }
          }
          // 新增订单结束
        } catch (error) {
          tip.loaded();
        }
      },
      youshuTrack(json) {
        try {
          this.$sr.track('custom_order', {
            order: {
              order_id: json.data?.orderCode.toString(),
              order_time: new Date(json.data?.orderTime.replace(/-/g, "/")).getTime() || new Date(json.data
                ?.orderTime).getTime(),
              order_status: 'give_order'
            },
            sub_orders: [{
              sub_order_id: json.data?.orderCode.toString(),
              order_amt: parseFloat(this.orderDetail?.itemTotal),
              pay_amt: parseFloat(this.orderDetail?.payment)
            }]
          });
        } catch (error) {}
      },
      // 获取优惠券列表
      getCouponList: async function() {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let jwt = customerInfo.jwt;
        const couponList = await api.getPayCouponItem({
            method: 'GET',
            header: {
              jwt: jwt
            },
            query: {}
          },
          that.realCartKey
        );

        if (couponList.code === 1000) {
          if (couponList.data.length > 0 || couponList.data !== '') {
            let coulist = couponList.data;
            let ruleIds = [];
            for (let i in coulist) {
              ruleIds.push(coulist[i].couponRuleId);
            }
            that.couponRuleIds = ruleIds;
            that.getMemberCouponsByRuleIds(that.couponRuleIds, false);
          }
        }
      },

      radioChange(e) {
        let that = this;
        that.payTypeChange = e.detail.value;
        let tempPayType = that.payTypeChange;
        switch (tempPayType) {
          case 'Wechat':
            that.payType = 'wosai:weixin:mini';
            break;
          case 'Shouqianba':
            that.payType = 'wosai:weixin:mini';
            break;
          case 'GiftCard':
            that.payType = 'wosai:weixin:mini:giftcard';
            break;
        }
        that.getAddressInfo(uni.getStorageSync(ADDRESS_ID));
      },

      bindKeyInput(e) {
        if (this.couponValue.length !== e.detail.value.length) {
          this.couponMessage = '';
        }
        this.couponValue = e.detail.value;
      },
      useCoupon: async function(e) {
        let that = this;
        let couponValue = this.couponValue || e.currentTarget.dataset.couponcode;
        this.couponRuleName = e.currentTarget.dataset.rulename;
        this.getCoupon = 0;

        if (couponValue != '' && couponValue != undefined) {
          let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
          let jwt = customerInfo.jwt;
          const json = await api.useCoupon({
              method: 'PUT',
              header: {
                jwt: jwt
              },
              query: {}
            },
            that.realCartKey,
            couponValue
          );
          if (json.code === 1000) {
            this.getCartList();
          } else if (
            json.code == -1000 ||
            json.code == -1001 ||
            json.code == -1002 ||
            json.code == -1013 ||
            json.code == -1015 ||
            json.code == -1016
          ) {
            this.handleShowTextToast('抱歉！该优惠券不可用');
            this.couponValue = '';
          } else if (json.code == -1011 || json.code == -1014) {
            this.handleShowTextToast('抱歉！该优惠券使用次数已超限');
            this.couponValue = '';
          } else if (json.code == -1012) {
            this.handleShowTextToast('抱歉！该优惠券已过期');
            this.couponValue = '';
          }
        } else {
          this.handleShowTextToast('请输入优惠券');
          // this.couponMessage = "请输入优惠券";
        }
      },
      // 取消使用优惠券
      clearUseCoupon: async function() {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let jwt = customerInfo.jwt;
        const json = await api.clearCoupon({
            method: 'PUT',
            header: {
              jwt: jwt
            },
            query: {}
          },
          that.realCartKey
        );
        if (json.code === 1000) {
          this.handleShowTextToast('取消成功');
          this.couponShow = false;
          this.getCartList();
        } else {
          this.handleShowTextToast(json.msg);
        }
      },
      isShow(e) {
        var that = this;
        this.isShowNotice = e;
      },

      goPays: async function() {
        let that = this;
        that.trackOrderSubmit();
        if (!that.is_exit_address) {
          // await tip.confirm('你未设置收货地址，请设置地址');
					this.$refs.toastPopup.showPopup({
						msg:"您未设置收货地址，请设置地址",
						callBackData: {
							type: "setUserAddress",
						}})
          return false;
        }

        if (!this.checked) {
          this.handleShowTextToast('请勾选销售条款');
          return false;
        } else {
          const r = await requestSubscribeMessageSync(['dvgPNQb-7HCYp09b7d-Tc6D6fGkcEOHY_lDOwK89COc'])
          if (r.length) {
          	this.needSendWaitForPaySubscribeMessage = true
          }
          // this.isAgreement = true;
          // that.$commonSensors.popupEvent('PopupExposure', {'popup_type' : '购买', 'popup_name': '确认提交订单弹窗'})
					//	个性化定制商品订单，需要先弹窗
					if(this.isUserC2bOrder){
						this.showC2bConfirmDialog = true;
					}else{
						this.goPay()
					}
        }
      },
      //商城-订单-提交订单---用户点击提交订单后返回此数据
      trackOrderSubmit() {
        let that = this;
        let clTrackPrams = {
          'c_product_id': '',
          'c_product_name': '',
          'c_product_brand': '',
          'c_product_price': '',
          'c_product_year': '',
          'c_product_series': '',
          'c_product_scenarios': '',
          'c_product_taste': '',
          'c_product_alcoholconcentration': '',
          'c_product_volume': '',
          'c_order_id': '',
          'c_quantity': this.orderDetail.checkedTotalQty,
          'c_order_remark': '',
          'c_amount': this.orderDetail.payment,
          'c_campaignID': '',
          'c_campaignName': '',
          'c_order_type': '常规购买',
          'c_purchase_type': this.$programSetting.openAppointment ? "立即预约" : "立即购买",
        }
        that.list.forEach(function(item, index) {
          clTrackPrams.c_product_id += item.itemId + ';';
          clTrackPrams.c_product_name += item.itemName + ';';
          clTrackPrams.c_product_price += item.price + ';';
          clTrackPrams.c_product_volume += item.skuProperties[0].valueName + ';';
        });
        getApp().commonClTrack('c_ebmp_order_submit_new', clTrackPrams)
      },
      async goPay(e) {
        let that = this;
        this.isAgreement = false
        if (this.$programSetting.openAppointment) {
          that.$commonSensors.popupEvent('PopupExposure', {'popup_type' : '订阅消息', 'popup_name': '订阅消息弹窗'})
          that.$commonSensors.modelAuthAsk('订单', ['r4wNA5QY9hWJl9oWxHyrq_MJndwOSKo1xYKi83rB7YM'])
          uni.requestSubscribeMessage({
            tmplIds: ['r4wNA5QY9hWJl9oWxHyrq_MJndwOSKo1xYKi83rB7YM'],
            complete(res) {
              if (!!that.showLoaded) {
                return false
              } else {
                that.showLoaded = true
                var fId = e?.detail?.formId || "";
                if (!that.operating) {
                  that.showLoaded = false
                  return false;
                }
                //判断是否有备注内容
                if (that.orderRemarks !== '' && that.orderRemarks !== null && that.orderRemarks !== undefined) {
                  that.setRemarks(that.orderRemarks, 'input');
                } else {
                  that.testAddress(uni.getStorageSync(ADDRESS_ID), fId);
                }
              }
              that.$commonSensors.popupEvent('PopupClick', {'popup_type' : '订阅消息', 'popup_name': '订阅消息弹窗', 'button_name': res['r4wNA5QY9hWJl9oWxHyrq_MJndwOSKo1xYKi83rB7YM'] == "accept" ? '允许' : '拒绝'})
            }
          });
        } else {
          if (!!that.showLoaded) {
            return false
          } else {
            that.showLoaded = true
            var fId = e?.detail?.formId || "";
            if (!that.operating) {
              that.showLoaded = false
              return false;
            }
            //判断是否有备注内容
            if (that.orderRemarks !== '' && that.orderRemarks !== null && that.orderRemarks !== undefined) {
              that.setRemarks(that.orderRemarks, 'input');
            } else {
              that.testAddress(uni.getStorageSync(ADDRESS_ID), fId);
            }
          }
        }

      },
      setAddress() {
        uni.navigateTo({
          url: '/pages/customer/address?type=order'
        });
      },

      /**
       * 获取提交订单时选择地址并设置地址和设置支付方式
       * @param id
       * @returns {Promise<void>}
       */
      sourceBind: async function() {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let customerId = customerInfo.customerId;
        let jwt = customerInfo.jwt;
        // 获取商户配置属性 判断是微信还是收钱吧
        let merchantInfo = uni.getStorageSync(MERCHANT_INFO);
        let sourceInfo = uni.getStorageSync('sourceInfo');
        let timeStamp = new Date().getTime();
        if (sourceInfo.expirationTime > timeStamp) {
          // 获取顾客地址信息
          const json = await api.sourceBind({
              method: 'PUT',
              header: {
                jwt: jwt
              },
              query: {
                uid: customerInfo.openId,
                utmCampaign: '',
                utmContent: '',
                utmMedium: sourceInfo.utmMedium,
                utmSource: sourceInfo.utmSource,
                utmTerm: sourceInfo.utmTerm
              }
            },
            that.realCartKey
          );
          if (json.code === 1000) {}
        }
      },

      cartItems: async function() {
        let that = this;
        that.$commonFunction.getCartList(that.realCartKey).then((res) => {
          let shopCollect = res
          that.cartBagItems = res
          let cartlistData = shopCollect.items;
          let discountsArr = [];
          let stockNullList = [];
          let stockNumber = [];
          let stocklessQty = [];
          let stockHaveList = [];
          if (cartlistData !== null && cartlistData.length > 0) {
            that.buttonShow = false;
            that.totalPrice = shopCollect.total;
            that.itemTotal = shopCollect.itemTotal;
            that.payment = shopCollect.payment;

            if (shopCollect.allGifts != '' && shopCollect.allGifts != null && shopCollect.allGifts != undefined) {
              that.allGifts = true;
            }
            that.discountFee = shopCollect.discountFee;
            that.postFee = shopCollect.postFee;
            that.couponFee = shopCollect.couponFee;
            that.disTotal = Number(that.discountFee / 1) + Number(that.couponFee / 1);
            that.disTotal = that.disTotal.toFixed(2);

            for (var i = 0; i < cartlistData.length; i++) {
              if (cartlistData[i]['skuProperties']) {
                cartlistData[i].skuProperties = JSON.parse(cartlistData[i]['skuProperties']);
              }
              if (cartlistData[i].discounts && cartlistData[i].discounts.length > 0) {
                for (let j = 0; j < cartlistData[i].discounts.length; j++) {
                  if (cartlistData[i].discounts[j].isCoupon == 0 && discountsArr.indexOf(cartlistData[i]
                      .discounts[j].discountName) == -1) {
                    discountsArr.push(cartlistData[i].discounts[j].discountName);
                  }
                }
              }

              // 赠品名称
              if (cartlistData[i].isGift == 1) {
                that.giftName = cartlistData[i].itemName;
              } else {
                that.giftName = '';
              }

              // 库存判断
              if (cartlistData[i]['stockQty'] == 0 || cartlistData[i].inValid == 1 || cartlistData[i]
                .skuProperties[0].approveStatus == 'instock') {
                cartlistData[i].safe = -1;
                stockNumber.push(i);
                stockNullList.push(cartlistData[i]);
              } else if (cartlistData[i]['stockQty'] <= cartlistData[i]['qty'] + this.safeNum && cartlistData[i]
                .inValid !== 1) {
                if (cartlistData[i]['stockQty'] < cartlistData[i]['qty']) {
                  this.addGoodNum(cartlistData[i]['skuId'], cartlistData[i]['stockQty'], i);
                  cartlistData[i]['qty'] = cartlistData[i]['stockQty'];
                }
                cartlistData[i].safe = 0;
                stockHaveList.push(cartlistData[i]);
              } else {
                if (cartlistData[i].inValid !== 1) {
                  cartlistData[i].safe = 2;
                  stockHaveList.push(cartlistData[i]);
                }
              }
              this.totalNum += cartlistData[i].stockQty;

              if (shopCollect.customerAddressId) {
                uni.setStorageSync(ADDRESS_ID, shopCollect.customerAddressId);
              }
            }
            this.discountsArr = discountsArr;
            let cartItems = cartlistData;
            this.cartNum = shopCollect.availableTotalQty;
          } else {
            uni.removeStorageSync('cartNum');
            this.cartNum = 0;
            that.buttonShow = true;
          }
          that.listData = stockHaveList.concat(stockNullList);
          that.cartHaveQty = stockHaveList;
          for (var j = 0; j < that.cartHaveQty.length; j++) {
            // 是否全部选中
            if (!that.cartHaveQty[j].isChecked) {
              this.allChecked = false;
            }
          }
          that.showLoaded = false;

          that.isClickCoupon = !that.isClickCoupon;
          // 每次购物车商品变化都要重新判断优惠券
          this.getCouponList(true);
        }).catch((err) => {
          this.handleShowTextToast(err.msg);
        })
      },
      // 显示输入和查看优惠券
      couponOpenshow() {
        let that = this;
        this.couponShow = !this.couponShow;
        this.couponMessage = '';
      },

      // 显示可用优惠券
      couponOpen() {
        this.isShowCouponList = true;
      },

      // 关闭可用优惠券
      closeCoupon() {
        let that = this;
        // that.getCoupon = 0;
      },
      // 手动输入优惠券码
      bindKeyInput(e) {
        if (this.couponValue.length !== e.detail.value.length) {
          this.couponMessage = '';
        }
        this.couponValue = e.detail.value;
      },
      useCoupon: async function(e) {
        let that = this;
        let couponValue = e.currentTarget.dataset.couponcode;
        this.couponRuleName = e.currentTarget.dataset.rulename;
        // this.getCoupon = 0;
        this.isShowCouponList = false;

        if (couponValue != '' && couponValue != undefined) {
          let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
          let jwt = customerInfo.jwt;
          const json = await api.useCoupon({
              method: 'PUT',
              header: {
                jwt: jwt
              },
              query: {}
            },
            that.realCartKey,
            couponValue
          );
          if (json.code === 1000) {
            this.getCartList();
            this.saveCoupon = couponValue;
          } else if (
            json.code == -1000 ||
            json.code == -1001 ||
            json.code == -1002 ||
            json.code == -1013 ||
            json.code == -1015 ||
            json.code == -1016
          ) {
            this.handleShowTextToast('抱歉！该优惠券不可用');
            // this.couponValue = '';
            this.useCouponHasChoose(this.saveCoupon);
            // this.clearUseCoupon(true)
          } else if (json.code == -1011 || json.code == -1014) {
            this.handleShowTextToast('抱歉！该优惠券使用次数已超限');
            // this.clearUseCoupon(true)
          } else if (json.code == -1012) {
            this.handleShowTextToast('抱歉！该优惠券已过期');
            // this.couponValue = '';
            this.useCouponHasChoose(this.saveCoupon);
            // this.clearUseCoupon(true)
          }
        } else {
          this.handleShowTextToast('请输入有效的优惠券');
          // this.couponMessage = "请输入优惠券";
        }
      },
      useCouponByInput: async function(e) {
        let that = this;
        let couponValue = this.couponValue || e.currentTarget.dataset.couponcode;
        this.couponRuleName = e.currentTarget.dataset.rulename;
        // this.getCoupon = 0;
        this.isShowCouponList = false;

        if (couponValue != '' && couponValue != undefined) {
          let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
          let jwt = customerInfo.jwt;
          const json = await api.useCoupon({
              method: 'PUT',
              header: {
                jwt: jwt
              },
              query: {}
            },
            that.realCartKey,
            couponValue
          );
          if (json.code === 1000) {
            this.getCartList();
            this.saveCoupon = couponValue;
          } else if (
            json.code == -1000 ||
            json.code == -1001 ||
            json.code == -1002 ||
            json.code == -1013 ||
            json.code == -1015 ||
            json.code == -1016
          ) {
            this.errorCouponWarn = '请输入有效的优惠券';
            setTimeout(function() {
              that.errorCouponWarn = '';
            }, 2000);
            if (!!this.saveCoupon) {
              this.useCouponHasChoose(this.saveCoupon);
            }
          } else if (json.code == -1011 || json.code == -1014) {
            this.errorCouponWarn = '抱歉！该优惠券使用次数已超限';
            setTimeout(function() {
              that.errorCouponWarn = '';
            }, 2000);
            if (!!this.saveCoupon) {
              this.useCouponHasChoose(this.saveCoupon);
            }
          } else if (json.code == -1012) {
            this.errorCouponWarn = '抱歉！该优惠券已过期';
            setTimeout(function() {
              that.errorCouponWarn = '';
            }, 2000);
            if (!!this.saveCoupon) {
              this.useCouponHasChoose(this.saveCoupon);
            }
          }
        } else {
          this.errorCouponWarn = '请输入有效的优惠券';
          setTimeout(function() {
            that.errorCouponWarn = '';
          }, 2000);
          if (!!this.saveCoupon) {
            this.useCouponHasChoose(this.saveCoupon);
          }
        }
      },
      // 恢复已选优惠券
      useCouponHasChoose: async function(couponValue) {
        if (couponValue != '' && couponValue != undefined) {
          let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
          let jwt = customerInfo.jwt;
          const json = await api.useCoupon({
              method: 'PUT',
              header: {
                jwt: jwt
              },
              query: {}
            },
            that.realCartKey,
            couponValue
          );
          if (json.code === 1000) {
            this.getCartList();
          } else if (
            json.code == -1000 ||
            json.code == -1001 ||
            json.code == -1002 ||
            json.code == -1013 ||
            json.code == -1015 ||
            json.code == -1016
          ) {
            this.handleShowTextToast('抱歉！该优惠券不可用');
            this.couponValue = '';
            // this.clearUseCoupon(true)
          } else if (json.code == -1011 || json.code == -1014) {
            this.handleShowTextToast('抱歉！该优惠券使用次数已超限');
            // this.clearUseCoupon(true)
          } else if (json.code == -1012) {
            this.handleShowTextToast('抱歉！该优惠券已过期');
            this.couponValue = '';
            // this.clearUseCoupon(true)
          }
        } else {
          this.handleShowTextToast('请输入有效的优惠券');
          // this.couponMessage = "请输入优惠券";
        }
      },
      // 取消使用优惠券
      clearUseCoupon: async function(bool) {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let jwt = customerInfo.jwt;
        const json = await api.clearCoupon({
            method: 'PUT',
            header: {
              jwt: jwt
            },
            query: {}
          },
          that.realCartKey
        );
        if (json.code === 1000) {
					this.handleShowTextToast('取消成功');
          that.placeholder = '请输入优惠券码';
          this.couponShow = false;
          this.getCartList();
        } else {
          this.handleShowTextToast(json.msg);
        }
      },

      /**
       * 获取可用优惠券列表
       * 自动发放的满足条件直接显示，需领取的领取之后才显示
       * 判断优惠券是否可用
       */

      getMemberCouponsByRuleIds: async function(couponRuleIds, noOpen) {
        let that = this;
        that.usableCoupon = [];
        let jwt = uni.getStorageSync(CUSTOMER_INFO).jwt;
        const couponList = await api.getValidCoupon({
            method: 'GET',
            header: {
              jwt: jwt
            },
            params: {}
          },
          couponRuleIds
        );
        if (couponList.code === 1000) {
          if (couponList.data.length > 0) {
            let usableCouponList = couponList.data;
            for (let i in usableCouponList) {
              if (usableCouponList[i].timesUsed < usableCouponList[i].timesLimit) {
                that.usableCoupon.push(usableCouponList[i]);
              }
              let c_item = [];
              let couponFailureTime = '';
              for (let j in that.usableCoupon) {
                c_item = that.usableCoupon[j];

                if (c_item.expirationDate != null && (c_item.expirationDate != undefined) & (c_item.expirationDate !=
                    '')) {
                  couponFailureTime = util.UTCformat(c_item.expirationDate);
                } else {
                  couponFailureTime = util.UTCformat(c_item['couponRule'].toDate);
                }

                let timearr = couponFailureTime.split(' '); //只取年月日
                c_item['couponRule'].toDate = timearr[0];
              }
              if (that.usableCoupon.length > 0 && !noOpen) {
                that.isShowCouponList = true;
              }
            }
          }
        }
      },
      // 获取优惠券列表
      getCouponList: async function(noOpen) {
        let that = this;
        let customerInfo = uni.getStorageSync(CUSTOMER_INFO);
        let jwt = customerInfo.jwt;
        const couponList = await api.getPayCouponItem({
            method: 'GET',
            header: {
              jwt: jwt
            },
            query: {}
          },
          that.realCartKey
        );
        if (couponList.code === 1000) {
          that.usableCoupon = [];
          if (couponList.data.length > 0 || couponList.data !== '') {
            let coulist = couponList.data;
            let ruleIds = [];
            for (let i in coulist) {
              ruleIds.push(coulist[i].couponRuleId);
            }
            that.couponRuleIds = ruleIds;
            that.getMemberCouponsByRuleIds(that.couponRuleIds, true);
          }
        }
      },
      showUseCouponClick() {
        this.showUseCoupon = !this.showUseCoupon;
      }
    }
  };
</script>
<style lang="less">
  .comfire_order{
    font-family: FrankNew-Regular,NotoSansSC-Regular;
  }
  .font_24{
    font-size: 24rpx;
  }
  .font_28{
    font-size: 28rpx;
  }
  .color_757575{
    color: #757575;
  }
  .color_000000{
    color: #000000;
  }
  .color_1a1a1a{
    color: #1a1a1a;
  }
  // 地址
  .address {
    background: #fff;
    .empty_address,
    .address_info {
      position: relative;
      display: flex;
      justify-content:flex-start;
      align-items: flex-start;
      padding: 32rpx;
      margin: 40rpx 48rpx 0;
      background-color: #fafafa;
      .location_icon{
        width: 48rpx;
        height: 48rpx;
        margin-right: 16rpx;
      }
      .title_info {
        width: 462rpx;
        margin-left:16rpx;
      }
      .user_name {
        color: #1a1a1a;
        margin-bottom: 48rpx;
        font-family: NotoSansSC-Medium;
        font-size: 28rpx;
        font-weight: 500;
        line-height: 48rpx;
      }
      .phone_style{
        color: #757575;
        font-family: FrankNew-Regular;
        font-size: 28rpx;
        font-weight: 400;
        line-height: 48rpx;
      }
      .arrow_right{
        width: 48rpx;
        height: 48rpx;
        position: absolute;
        right: 32rpx;
        top:50%;
        margin-top: -24rpx;
      }

      .defult {
        color: #ff571a;
      }
    }
  }

  // 提示
  .tips {
    display: flex;
    margin: 0 35rpx;
    font-size: 25rpx;

    .text {
      flex: 1
    }
  }

  .tip_box {
    margin-left: 48rpx;
    margin-right: 48rpx;
    padding-top: 24rpx;
    position: relative;
    border-top: 1px solid #f2f2f2;
    font-family: NotoSansSC-Regular !important;
  }

  .tip_box_show{
    padding-bottom: 580rpx;
  }
  .tip_box_hidden{
    padding-bottom: 450rpx;
  }

  .bottom-agreement {
    background-color: #fff;
    border-bottom: 1px solid #f2f2f2;
  }

  .agreement {
    margin: 32rpx 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  .agreement-left{
    width:32rpx;
    height:32rpx;
    flex-shrink:0;
    margin-right: 24rpx;
    margin-top: 2px;
  }
  .agreement-right{
    font-family: FrankNew-Regular,NotoSansSC-Regular;
    line-height: 40rpx;
  }

  .order_info {
    .block {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 30rpx 35rpx;
      border-bottom: 1px solid #e7e7e7;
      background: #fff;

      .txt {
        font-size: 32rpx;
      }

      .right {
        color: #9a9a9a;
      }

      .price {
        color: #ea4a3a;
        font-size: 32rpx;
      }

      .tongji {
        margin-bottom: 20rpx;
      }

      .total_jf {
        font-size: 32rpx;
      }
    }
  }

  .goods-info {
    width: 100%;
    height: 352rpx;
    display: flex;
    box-sizing: border-box;
    position: relative;
    // margin-bottom: 16rpx;
    background-color: #fafafa;
  }
  .goods-info .img-box {
    width: 264rpx;
    height: 100%;
  }

  .goods-info .text-box {
    width: 390rpx;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    padding-right: 48rpx;
  }

  .goods-info .text-box .goods-title {
    color: #000;
    padding: 0;
    font-size: 28rpx;
    line-height: 48rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; // 控制多行的行数
    -webkit-box-orient: vertical;
    font-family: NotoSansSC-Medium;
    font-weight: 500;
  }
	
	.goods-title1{
		-webkit-line-clamp: 1 !important; // 控制多行的行数
	}

  .goods-info .text-box .goods-label {
    font-size: 26rpx;
    color: #999;
    height: 38rpx;
    line-height: 38rpx;
    margin: 8rpx 0 25rpx 0;
  }

  .lable {
    display: flex;

    .goods-label {
      font-size: 26rpx;
    }

    .goods-lable {
      font-size: 26rpx;
    }
  }

  .num-change {
    width: 190rpx;
    height: 64rpx;
    box-sizing: border-box;
    border: 1px solid #f2f2f2;
    display: flex;
    font-size: 26rpx;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    text-align: center;

    .jian-btn {
      width: 40rpx;
      height: 40rpx;
      font-size: 36rpx;
    }


    .numjia {
      width: 40rpx;
      height: 40rpx;
      font-size: 36rpx;
    }



    input {
      border: none;
      width: 70rpx;
      height: 48rpx;
      min-height: 48rpx;
      text-align: center;
      font-size: 30rpx;
      z-index: 1;
    }

    .buy-number {
      border: none;
      width: 70rpx;
      text-align: center;
      font-size: 28rpx;
      z-index: 1;
      font-family: FrankNew-Regular;
    }
  }



  .goods-info .text-box .buy-num {
    line-height: 39rpx;
    color: #aeaeae;
  }

  .outerLayer {
    width: 54rpx;
    height: 100%;
    display: flex;
    align-items: center;
  }

  .flex_end{
    justify-content: flex-end;
  }
  .flex_start{
    justify-content: flex-start;
  }

  // .jian-button {
  //   width: 50rpx;
  //   height: 70rpx;
  //   display: flex;
  //   justify-content: flex-end;
  //   align-items: center;
  //   margin-right: 10rpx;
  // }

  // .jia-button {
  //   width: 50rpx;
  //   height: 70rpx;
  //   display: flex;
  //   justify-content: flex-start;
  //   align-items: center;
  //   margin-left: 10rpx;
  // }

  .goods-info .text-box .buy-num .jian-btn {
    width: 48rpx;
    height: 100%;
    border-left: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    border-top: 1px solid #ccc;
    border-bottom-left-radius: 6rpx;
    border-top-left-radius: 6rpx;
  }

  .goods-info .text-box .buy-num .jian-btn.disabled {
    background-color: #f5f5f9;
    border-left: 1px solid #eee;
    border-bottom: 1px solid #eee;
    border-top: 1px solid #eee;
    color: #ccc;
  }

  .goods-info .text-box .buy-num .jia-btn {
    width: 48rpx;
    height: 100%;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    border-top: 1px solid #ccc;
    border-bottom-right-radius: 6rpx;
    border-top-right-radius: 6rpx;
  }

  .goods-info .text-box .buy-num .jia-btn.disabled {
    background-color: #f5f5f9;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    border-top: 1px solid #eee;
    color: #ccc;
  }

  .goods-info .text-box .buy-num input {
    width: 68rpx;
    height: 48rpx;
    min-height: 48rpx;
    text-align: center;
    font-size: 24rpx;
    border: 1px solid #ccc;
  }

  .goods-info .img-box .img {
    width: 100%;
    height: 100%;
  }

  .dk-jf {
    text-align: right;
    color: #666;
  }

  .o-order-summary {
    width: 100%;
    display: flex;
    flex-direction: column;
    font-size: 27rpx;
  }

  .o-order-summary span:nth-of-type(2) {
    float: right;
  }

  .order_money {
    display: block !important;
    height: auto !important;
  }

  .goodsList {
    padding: 48rpx 48rpx 0 48rpx;
  }

  .goodsList .tongji {
    margin-bottom: 20rpx;
  }

  .list_box {
    // background-color: #fafafa;
    margin-bottom: 16rpx;
  }

  .list_box:last-child{
    margin-bottom: 0;
  }
  // .list_box:last-child {
  //   padding: 0;
  //   margin: 0;
  //   border-bottom: none;
  // }

  .goods-price,
  .linePrice,
  .nowPrice {
    font-size: 36rpx;
  }

  .mark {
    margin-right: 4rpx;
    font-family: NotoSansSC-Regular;
  }

  .total-section {
    text-align: right;
    padding-right: 10rpx;
  }

  .buy-num view {
    font-family: 'mHei', serif;
    line-height: 58rpx;
  }

  .active_address .defult {
    display: none;
  }

  .coupon_box {
    display: flex;
    width: 100%;
  }

  .coupon_box input {
    padding-left: 8rpx;
    width: 75%;
    background-color: #e7e7e7;
    height: 52rpx;
  }

  .coupon_box .btnStyle {
    width: 40%;
    height: 52rpx;
    line-height: 52rpx;
  }

  .coupon_act {
    font-size: 27rpx;
  }

  .coupon_act text {
    float: right;
  }

  .goods-info .text-box .lable {
    font-size: 26 rpx;
    color: #999;
    margin: 10rpx 0;
  }

  .goods-info .lable {
    display: flex;
    flex-direction: column;
  }

  .goods-info .lable .bo-label {
    color: #757575;
    font-size: 24rpx;
    font-family: FrankNew-Regular;
    line-height: 40rpx;
  }

  .bottomBox {
    width:100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .icon-jiantou32,
  .icon-jiantou31 {
    font-size: 32rpx;
  }

  .icon-jiantouxiangyou {
    font-size: 40rpx;
    width: 32rpx;
    color: #666;
  }

  .m-radio-button-selector {
    padding: 20rpx 35rpx;
  }

  .m-radio-button-selector .title {
    margin-bottom: 20rpx;
  }

  .m-radio-button {
    padding: 30rpx;
    background-color: #f9f9f9;
  }

  .m-radio-button .custom-radio {
    float: right;
    width: 20px;
    height: 20px;
  }

  .a-radio-button.is-checked+.custom-radio:after,
  .a-radio-button:checked+.custom-radio:after {
    background-color: #000;
    content: ' ';
    width: 16rpx;
    height: 16rpx;
    border-radius: 50%;
    display: inline-block;
    position: absolute;
    top: 12rpx;
    left: 12rpx;
    border: 1px solid #f8f8f8;
  }

  .m-radio-button .a-label.label-text {
    font-size: 15px;
    display: inline-block;
    margin-right: 0;
    width: 50%;
  }

  .m-radio-button .a-label.label-text.sqb {
    padding-left: 50rpx;
    background: url('https://efs-cloud-miniprogram-store-1252208446.cos.ap-shanghai.myqcloud.com/fonts/svg/wxPay.svg') no-repeat left center;
    background-size: 18px 18px;
  }

  .m-radio-button p.a-paragraph {
    height: 40rpx;
    line-height: 40rpx;
    padding-left: 10rpx;
  }

  .m-radio-button .a-radio-button {
    display: none;
    cursor: pointer;
  }

  .a-radio-button+.custom-radio {
    background-color: #e7e7e7;
    cursor: pointer;
    box-sizing: border-box;
    position: relative;
    display: inline-block;
    width: 28rpx;
    height: 28rpx;
    border-radius: 50%;
    vertical-align: top;
  }

  .m-radio-button .custom-radio {
    float: right;
    width: 40rpx;
    height: 40rpx;
  }

  .shipping-section.freight {
    margin-bottom: 20rpx;
  }

  .saleText_2 {
    color: #ff571a;
    // margin: 10rpx 0;
  }

  .saleTab {
    color: #ff571a;
  }

  .text-box .saleTab span {
    color: #ff571a;
    padding-right: 10rpx;
  }

  /* 优惠券弹窗 */
  .couponItem {
    background-color: #fff;
    padding: 0 10px 8rpx 10px;
    box-shadow: 0 1px 10px #666;
    margin: 20rpx 30rpx;
    position: absolute;
    top: 25%;
    width: 86%;
    z-index: 1002;
  }

  .couponItem .coucontent {
    margin-bottom: 30rpx;
  }

  .couponItem .cousubstance {
    background-color: #f5f5f5;
    padding: 40rpx;
  }

  .couponItem h4 {
    font-size: 36rpx;
    display: block;
    margin-bottom: 10rpx;
  }

  .couponItem .copRule {
    border-top: 1px solid #d2d2d2;
    padding-top: 24rpx;
    text-align: right;
    overflow: hidden;
  }

  .couponItem .copRule span {
    float: left;
  }

  .couponItem .description {
    padding-top: 8rpx;
    overflow: hidden;
    display: block;
    margin-bottom: 20rpx;
  }

  .couponItem .btn.s2 {
    background-color: #fff;
    color: #444;
    border: 1px solid #999;
  }

  .couponItem .icon-cuowu1 {
    font-size: 58rpx;
    position: absolute;
    right: 0;
    top: 0;
    width: 80rpx;
  }

  .discounts-arr-box {
    max-width: 270px;
  }

  .discounts-item {
    display: block;
    text-align: right;
  }

  .discounts-item:last-child {
    padding-right: 0;
    border-right: 1px solid transparent;
  }

  .distribution {
    display: flex;
    justify-content: space-between;
    font-family: NotoSansSC-Regular;
    width: 100%;
    height:64rpx;
    line-height: 64rpx;
    margin-top: 48rpx;
    margin-bottom: 16rpx;
  }

  .order-remarks {
    display: flex;
    align-items: center;
    padding: 30rpx 0;
    font-size: 32rpx;
    margin: 10rpx 48rpx;

    .title {
      margin-right: 20rpx;
    }

    .input {
      flex: 1;
      margin-top: 4rpx;

      input {
        color: #ddd;
        font-size: 26rpx;
      }
    }
  }

  .no-address {
    background-color: #c6c6c6 !important;
    color: #757575 !important;
  }

  .linePrice {
    text-decoration: line-through;
    color: #444444;
    font-size: 24rpx;
  }

  // 划线价
  .markPrice {
    display: flex;
    margin-top: 8rpx;

    .linePrice {
      text-decoration: line-through;
      font-size: 36rpx;
      line-height: 36rpx;
    }

    .nowPrice {
      margin-left: 10rpx;
      color: #862633;
      line-height: 36rpx;
    }
  }

  .cartTotal {
    margin-top: 40rpx;
    padding: 0 38rpx;
    padding-bottom: 120rpx;
  }

  .cartTotal .item {
    display: flex;
    justify-content: space-between;
    font-size: 26rpx;
    margin-bottom: 34rpx;
  }

  .cartTotal .item .look-coupon-list {
    border-bottom: 1px solid #000;
    line-height: 34rpx;
    font-size: 26rpx;
    margin-top: 2rpx;
  }

  .cartTotal .item .total {
    font-size: 26rpx;
    font-family: rutanRegular;
  }

  .cartTotal .item .coupon_act {
    color: #000;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    width: 80%;
  }

  .cartTotal .item .coupon_act .cancel-coupon {
    color: #999;
    border-bottom: 1px solid #999;
    display: inline-block;
    margin-right: 20rpx;
  }

  .couponInput {
    border: 1px solid #7f7f7f;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .couponInput input {
    width: 100%;
    height: 60rpx;
    line-height: 60rpx;
    font-size: 15px;
    padding: 0px;
    flex: 1;
    padding-left: 10rpx;
    font-size: 24rpx;
  }

  .couponInput .btn {
    height: 60rpx;
    line-height: 60rpx;
    background-color: #7f7f7f;
    color: #fff;
    font-size: 24rpx;
    width: 200rpx;
    text-align: center;
  }

  .couponList {
    padding: 40rpx;
    margin-top: 50rpx;
    padding-bottom: 200rpx;
  }

  .couponList .item {
    background-color: #f0f0f0;
    padding: 20rpx;
    margin-bottom: 30rpx;
    display: block;
    color: #999;
  }

  .couponList .item label {
    display: block;
    margin-bottom: 6rpx;
    font-size: 26rpx;
    color: #000;
  }

  .cartTotal .couponBox {
    position: relative;
    font-size: 26rpx;
    display: block;
  }

  .cartTotal .couponTitle {
    display: flex;
    justify-content: flex-end;
  }

  .cartTotal .aos_mp {
    font-size: 26rpx;
  }

  .cartTotal .aos_mp-arrow-down {
    width: 42rpx;
  }

  .cartTotal .aos_mp-arrow-down:before {
    content: '';
  }

  .cartTotal .aos_mp-arrow-down:after {
    content: '\e60c';
    font-size: 32rpx;
    position: absolute;
    right: 0;
    top: 0;
    color: #000;
  }

  .cartTotal .aos_mp-arrow-down.act {
    transform: rotate(180deg);
  }

  .cartTotal .couponInput .weui-input {
    border-bottom: 1px solid #000;
    height: 40rpx;
    margin-top: 10rpx;
  }

  .cartTotal .couponInput button {
    margin: 60rpx 0;
    text-align: center;
    border: 2px solid #000;
    border-radius: 0;
    background-color: #fff;
    font-size: 26rpx;
    font-family: syHeavy;
  }

  .cartTotal .couponName {
    margin-left: 30rpx;
  }

  .cartTotal .couponList {
    padding: 0 40rpx 200rpx 40rpx;
  }

  .cartTotal .couponList li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40rpx;
  }

  .cartTotal .couponList strong {
    display: block;
    font-size: 26rpx;
    font-family: syHeavy;
  }

  .couponText {
    display: flex;
  }

  .couponText .cancel {
    display: inline-block;
    color: #000;
    border-bottom: 1px solid #000;
  }

  /* 已加入购物车商品售完的情况 */
  .noGoods .goods-info .text-box .goods-title,
  .noGoods .goods-info .lable .bo-label,
  .noGoods .goods-info .markPrice .linePrice,
  .noGoods .goods-info .markPrice .nowPrice {
    color: #d8d8d8;
  }

  .noGoods .goods-info .text-box .buy-num {
    display: none;
  }

  .topBox {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    background-color: #fff;
    z-index: 9999;
    overflow-y: auto;
    margin-top: 116rpx;
    padding: 0;
  }

  .topBox .a-icon-close {
    top: 40rpx;
    right: 20rpx;
    position: absolute;
  }

  /* 提示 */
  .tipsRed {
    color: #ff571a;
    font-size: 22rpx;
    margin-bottom: 10rpx;
    font-family: syLIGHT;
  }

  /* 签名弹框 */
  .topBoxSmall .cont {
    height: auto;
  }

  .autograph {
    text-align: center;
    font-size: 28rpx;
  }

  .autograph .box {
    padding: 60rpx 0;
    line-height: 60rpx;
    width: 70%;
    margin: auto;
  }

  .autograph label {
    font-size: 30rpx;
    display: block;
    line-height: 56rpx;
  }

  .autograph .btnBox {
    display: flex;
    justify-content: center;
    margin-top: 50rpx;
  }

  .autograph .btnBox .btn1 {
    border: 1px solid #000;
    background-color: #fff;
    width: 200rpx;
  }

  .autograph .btnBox .btn2 {
    background-color: #000;
    color: #fff;
    border: none;
    margin-left: 30rpx;
    min-width: 200rpx;
  }

  .cpTitle {
    font-size: 36rpx;
    text-align: center;
    margin: 0 0 50rpx 0;
  }

  .couponItem {
    background-color: #f0f0f0;
    padding: 20rpx;
    margin-bottom: 30rpx;
  }

  .couponItem.act {
    border: 1px solid #000;
  }

  .couponItem label {
    display: block;
    color: #000;
    font-size: 26rpx;
  }

  .couponItem text {
    color: #999;
  }

  .salePrice {
    font-size: 26rpx;
  }

  .check_1 {
    background-color: #000;
    color: #fff;
    padding: 4rpx 4rpx 6rpx 4rpx;
    font-size: 23rpx;
    width: 28rpx;
    height: 26rpx;
    margin-top: 88rpx;
  }

  .discounts-arr-box {
    max-width: 270px;
  }

  .discounts-item {
    display: block;
    text-align: right;
  }

  .discounts-item:last-child {
    padding-right: 0;
    border-right: 1px solid transparent;
  }

  .warn-info {
    font-size: 26rpx;
    position: absolute;
    left: 0;
    top: 0rpx;
    color: #ff571a;
  }

  .cartTotal .giftBox {
    font-size: 26rpx;
    padding-top: 30rpx;
  }

  .warn-coupon {
    color: #ff571a;
    font-size: 26rpx;
    text-align: center;
  }

  .mb20 {
    margin-bottom: 20rpx;
  }

  .cartCoupon {
    padding-bottom: 8rpx;
    margin-bottom: 26rpx;
  }

  /* 已加入购物车商品售完的情况 */
  .noGoods .goods-info .text-box .goods-title,
  .noGoods .goods-info .lable .bo-label,
  .noGoods .goods-info .markPrice .linePrice,
  .noGoods .goods-info .markPrice .nowPrice {
    color: #d8d8d8;
  }

  .noGoods .goods-info .text-box .price {
    color: #d8d8d8;
  }

  .noGoods .goods-info .text-box .buy-num {
    display: none;
  }

  .cp {
    position: relative;
  }

  .icon-jiantouxiangyou.act {
    transform: rotate(270deg);
    left: 90rpx;
    top: 0;
  }

  .textareaBox {
    height: 50px;
    display: inline-block;
    width: 100%;
    border: 2rpx solid #ddd;
  }

  .bottomBar {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    border-top: 1px solid #f2f2f2;
    z-index: 10;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-shadow: 0px 0px 32px 0px #0000000A;
    // padding: 0 48rpx 22rpx 48rpx;
    padding: 0 48rpx 30rpx 48rpx;
    background-color: #fff;

    &.noBottom {
      padding-bottom: 0;
    }
  }

  .bottom_submit{
    width: 100%;
  }

  .order_show{
    height: 224rpx !important;
  }
  .order_hidden{
    height: 80rpx !important;
  }
  .order_value_section {
    padding-top: 32rpx;
    height: 80rpx;
    overflow: hidden;
    transition: all 300ms;
    display: flex;
    flex-direction: column-reverse;
    .order_item{
      width: 100%;
      height: 48rpx;
      line-height: 48rpx;
      margin-bottom: 24rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 28rpx;
      font-weight: 500;
    }
    .order_item:first-child{
      margin-bottom: 0;
    }
    .title {
      padding-right: 8rpx;
    }
    .arrow_top{
      width: 48rpx;
      height: 48rpx;
      transition: all 300ms;
    }
    .arrow_show{
      transform: rotate(-90deg);
    }
    .arrow_hidden{
      transform: rotate(90deg);
    }
    .mark2{
      padding-right: 4rpx;
    }
    .title,.mark {
      font-family: NotoSansSC-Medium;
    }
    .priceNum {
      font-family: FrankNew-Medium;
    }
    .title2,.mark2 {
      font-family: NotoSansSC-Regular;
    }
    .priceNum2 {
      font-family: FrankNew-Regular;
    }
    .priceNum,.priceNum2{
      padding-top: 1px;
    }
    .title2,.mark2,.priceNum2{
      font-weight: 400;
      color: #757575;
    }
  }

  .flex_style{
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .pay_box {
    width: 100%;
    height: 80rpx;
    margin: 32rpx 0 20rpx 0;
    .btnStyle {
      width: 286rpx;
      height: 90rpx;
      background-color: #CB171A;
      color: #fff;
    }
  }

  /*checkbox 整体大小  */
  checkbox {
    width: 40rpx;
    height: 40rpx;
  }

  /*checkbox 选项框大小  */
  checkbox .wx-checkbox-input {
    width: 30rpx;
    height: 30rpx;
  }

  /*checkbox选中后样式  */
  checkbox .wx-checkbox-input.wx-checkbox-input-checked {
    border: 1px solid #000;
    background-color: #fff;
  }

  /*checkbox选中后图标样式  */
  checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
    width: 28rpx;
    height: 28rpx;
    line-height: 28rpx;
    text-align: center;
    font-size: 22rpx;
    color: #000;
    background: transparent;
    transform: translate(-50%, -50%) scale(1);
    -webkit-transform: translate(-50%, -50%) scale(1);
  }

  // 协议弹框

  .popBg {
    background-color: rgba(0, 0, 0, 0.64);
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10010000;

    .success-pop {
      border: 1px solid #eee;
      position: absolute;
      text-align: center;
      top: 45%;
      background: #fff;
      z-index: 10010001;
      margin-top: -90rpx;
      padding: 40rpx 15rpx;
      width: 500rpx;
      left: 50%;
      margin-left: -250rpx;

      .title1 {
        font-weight: bold;
        line-height: 24px;
        font-size: 24rpx;
        margin: 20rpx 12rpx;
        line-height: 40rpx;
        text-align: left;

        &.title-order {
          margin: 20rpx 0 20rpx 50rpx;
        }

        .text {
          font-weight: bold;
          font-size: 24rpx;
          line-height: 40rpx;
          letter-spacing: 2rpx;
        }
      }

      .title2 {
        padding-bottom: 24rpx;
      }
    }

    .icon-cuowu1 {
      position: absolute;
      right: 12rpx;
      top: 12rpx;
      font-size: 42rpx;
      font-weight: bold;
    }

    .btn-bg {
      display: flex;
      justify-content: center;

      .btnStyle {
        text-align: center;
        border: 1px solid #999999;
        -webkit-border-radius: 0;
        border-radius: 0;
        background-color: #fff;
        margin: 0rpx 18rpx;
        width: 220rpx;
        height: 68rpx;
        line-height: 68rpx;
        color: #000;
        font-size: 24rpx;
      }

      .btn2 {
        background-color: #CB171A;
        color: #fff;
        border: none;
      }

      .btn1 {
        line-height: 66rpx;
      }
    }
  }

  .type_green {
    width: 100%;
    text-align: center;
    height: 80rpx;
    background-color: #000000;
    font-size: 28rpx;
    color: #ffffff;
    padding: 4px 8px 4px 8px;
    border-radius: 24px 8px 24px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: NotoSansSC-Regular;
    font-weight: 500;
  }

  .tip_inner{
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .tip_icon {
    width: 40rpx;
    height: 40rpx;
    text-align: center;
    flex-shrink: 0;
  }
  .tip_text{
    line-height: 40rpx;
  }

  .tip-text {
    display: block;
    margin: 37rpx 36rpx 0 36rpx;
    text-align: justify;
    font-size: 25rpx;
  }

  .tip-text2 {
    display: block;
    margin-left: 40rpx;
    text-align: justify;
    font-size: 25rpx;
    line-height: 40rpx;
  }

  .check-dec {
    font-family: FrankNew-Medium,NotoSansSC-Medium !important;
    color: #000000;
  }

  .imgText {
    position: relative;

    image {
      width: 100%;
      display: block;
    }

    .link1_1 {
      position: absolute;
      left: 40%;
      top: 50%;
      width: 60%;
      height: 9%;
    }

    .link1_2 {
      position: absolute;
      left: 0;
      top: 60%;
      width: 19%;
      height: 9%;
    }

    .link2_1 {
      position: absolute;
      left: 59%;
      top: 78%;
      width: 41%;
      height: 9%;
    }

    .link2_2 {
      position: absolute;
      left: 0;
      top: 88%;
      width: 28%;
      height: 9%;
    }
  }
	.c2b_order_box{
		width: 100%;
		height: 100rpx;
		line-height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 1rpx 48rpx 49rpx 48rpx;
		background-color: #fafafa;
	}
	.c2b_order_title{
		line-height: 50rpx;
		font-size: 24rpx;
		font-weight: 500;
		font-family: NotoSansSC-Medium;
	}
	.c2b_order_btn{
		height: 50rpx;
		line-height: 50rpx;
		border-bottom: 1px solid #000;
		border-top: 1px solid transparent;
		font-size: 24rpx;
		font-weight: 500;
		font-family: NotoSansSC-Regular;
	}
	.cart_number_box{
		position: relative;
		overflow: hidden;
	}
	.cart_number_input{
		position: absolute;
		left: -9999rpx;
		top: -9999rpx;
		z-index: -199;
		width: 54rpx;
		opacity: 0;
	}
</style>
